package Fright;

import org.junit.Test;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;

public class Fileoutput_ {
    public static void main(String[] args) {

    }
    @Test
    public void out(){
        String file="d:\\next2.txt";
        String file2="d:\\next3.txt";
        FileOutputStream fileOutputStream=null;
        FileInputStream fileInputStream=null;
        try {
             fileOutputStream=new FileOutputStream(file);
             fileInputStream=new FileInputStream(file2);
             //String str="hello,world";
            byte[] bytes=new byte[1024];
            int n=0;
             while ((n=fileInputStream.read(bytes))!=-1){
                 fileOutputStream.write(bytes,0,n);
            }

        } catch (IOException e) {
            e.printStackTrace();
        }try {
            if (fileOutputStream!=null){
            fileOutputStream.close();}
            if (fileInputStream!=null){
                fileInputStream.close();
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
